﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace TwoInOne
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.openFileDialog1.CheckFileExists = true;
        }
        private bool first = false;
        private bool second = false;

        private void button1_Click(object sender, EventArgs e)
        {
            this.first = true;
            this.openFileDialog1.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.second = true;
            this.openFileDialog1.ShowDialog();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                StreamReader read1 = new StreamReader(this.textBox1.Text);
                StreamReader read2 = new StreamReader(this.textBox2.Text);
                if (!Directory.Exists("./Data")) { Directory.CreateDirectory("./Data"); }
                StreamWriter writer1 = new StreamWriter("./Data/" + this.textBox3.Text);
                writer1.Write(read1.ReadToEnd() + "\n" + read2.ReadToEnd());
                writer1.Close();
                read1.Close();
                read2.Close();
                this.label1.Text = "成功！";
            }
            catch (Exception)
            {
                this.label1.Text = "创建失败";
            }
            


        }

        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            if (first)
            {
                this.first = false;
                this.textBox1.Text = this.openFileDialog1.FileName;
            }
            if (second)
            {
                this.second = false;
                this.textBox2.Text = this.openFileDialog1.FileName;
            }
        }
    }
}
